<template>
	<view class="refund">
		<view class="title">货款返回方式</view>
		<view class="order_title">
			<view class="title_left">支付宝</view>
			<input type="text" v-model="zfb" placeholder="请输入完整账户" />
		</view>
		<view class="order_title">
			<view class="title_left">收款人</view>
			<input type="text" v-model="payee" placeholder="请输入完整姓名" />
		</view>
		<view class="title">联系人信息</view>
		<view class="order_title">
			<view class="title_left">联系人</view>
			<input type="text" v-model="name" placeholder="请输入联系人姓名" />
		</view>
		<view class="order_title">
			<view class="title_left">联系电话</view>
			<input type="number" maxlength='11' v-model="phone" placeholder="请输入联系人电话" />
		</view>
		<view class="careful">请您仔细核对信息，错误的信息将导致退款失败！</view>
		<view class="button">
			<button type="warn" @click="addmanagement">提交</button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				zfb:'',
				payee:'',
				name:'',
				phone:'',
				goods:'',
				id:''
			};
		},
		onShow() {
			this.goods = JSON.parse(uni.getStorageSync('goods'));
			console.log(this.goods)
		},
		onLoad(e) {
			id=e.id
		},
		methods:{
			addmanagement(){
				if(this.zfb==''){
					return uni.showToast({
						title:'支付宝不能为空'
					})
				}
				if(this.payee==''){
					return uni.showToast({
						title:'收款人不能为空'
					})
				}
				if(this.name==''){
					return uni.showToast({
						title:'联系人不能为空'
					})
				}
				if(this.phone==''){
					return uni.showToast({
						title:'联系电话不能为空'
					})
				}else if(this.phone.length!=11){
					return uni.showToast({
						title:'联系电话为11位'
					})
				}
				if(id==1){
					this.$request('/app/order/reapplyRefund','post',{
						access_token:uni.getStorageSync('access_token').replace(/^\"|\"$/g,''),
						type:'1',
						linkman:this.name,
						linkphone:this.phone,
						account:this.zfb,
						name:this.payee,
						images:this.goods.img||'',
						money:this.goods.money,
						reason:this.goods.reason,
						option_id:this.goods.option_id,
						goods_id:this.goods.goods_id,
						order_sn:JSON.parse(uni.getStorageSync('order_sn'))
					}).then(res=>{
						uni.showToast({
							title:res.message
						})
						if(res.errcode==0){
							uni.navigateBack({
								delta:2
							})
						}
					})
				}else{
					this.$request('/app/order/refund','post',{
						access_token:uni.getStorageSync('access_token').replace(/^\"|\"$/g,''),
						type:'1',
						linkman:this.name,
						linkphone:this.phone,
						account:this.zfb,
						name:this.payee,
						images:this.goods.img||'',
						money:this.goods.money,
						reason:this.goods.reason,
						option_id:this.goods.option_id,
						goods_id:this.goods.goods_id,
						order_sn:JSON.parse(uni.getStorageSync('order_sn'))
					}).then(res=>{
						uni.showToast({
							title:res.message
						})
						if(res.errcode==0){
							uni.navigateBack({
								delta:2
							})
						}
					})
				}
			}
		}
	}
</script>

<style lang="less">
	.refund{
		background-color: #f3f4f5;
		height: 100%;
		.title{
			padding: 20rpx 30rpx;
			font-size: 28rpx;
			font-family: PingFangSC-Regular, PingFang SC;
			font-weight: 400;
			color: #9DA5A8;
		}
		.order_title {
			display: flex;
			padding: 30rpx;
			border-bottom: 1px solid #eeeeee;
			background-size: 28rpx 28rpx;
			background-color: #fff;
			.title_left {
				width: 120rpx;
				font-size: 28rpx;
				font-family: PingFangSC-Regular, PingFang SC;
				font-weight: 400;
				color: #111111;
				margin-right: 30rpx;
			}
			input{
				flex: 1;
				font-size: 28rpx;
			}
		}
		.careful{
			display: flex;
			align-items: center;
			justify-content: center;
			font-size: 24rpx;
			font-family: PingFangSC-Regular, PingFang SC;
			font-weight: 400;
			color: #DB1B22;
			margin-top: 40rpx;
		}
		.button {
				width: 90%;
				margin: 0 auto;
				padding: 40rpx 0;
				button{
					border-radius: 20px;
					line-height: 80rpx;
				}
			}
	}
</style>
